//
//  NSMutableArray+ImagePicker.m
//  ImagePicker
//
//  Created by csh on 16/4/14.
//  Copyright © 2016年 com.read. All rights reserved.
//
#import <Photos/Photos.h>
#import <AssetsLibrary/AssetsLibrary.h>
#import "DVAssetModel.h"
#import "NSMutableArray+ImagePicker.h"

@implementation NSMutableArray (ImagePicker)
- (void)deleteObject:(id)object
{
    DVAssetModel *deleteModel = nil;
    DVAssetModel *model = object;
    for(DVAssetModel *assetModel in self)
    {
        if([assetModel.asset isKindOfClass:[PHAsset class]])
        {
            PHAsset *asset1 = assetModel.asset;
            PHAsset *asset2 = model.asset;
            if([asset1.creationDate isEqual:asset2.creationDate])
            {
                deleteModel = assetModel;
            }
        }else
        {
            ALAsset *asset1 = assetModel.asset;
            ALAsset *asser2 = model.asset;
            if([[asset1 valueForProperty:ALAssetPropertyDate] isEqual:[asser2 valueForProperty:ALAssetPropertyDate]])
            {
                deleteModel = assetModel;
            }
        }
    }
    [self removeObject:deleteModel];
}
@end
